package cn.itcast.servlet;

import cn.itcast.domain.City;
import cn.itcast.service.CityService;
import cn.itcast.service.impl.CityServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/city")
public class CityServlet extends HttpServlet {

    private CityService cityService = new CityServiceImpl();
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            //调用service 查询所有城市信息
        List<City> cityList = cityService.findAll();

        req.setAttribute("city",cityList);
        req.getRequestDispatcher("/add.jsp").forward(req,resp);
    }
}
